1. Field of the Invention
The present invention relates generally to the data processing field, and more particularly, to a computer implemented method, system and computer program product for reducing threadprivate memory reference overhead in the presence of threadprivate variables in parallel programs during program compilation.
2. Description of the Related Art
OpenMP threadprivate variable is private to a thread but global within that thread. It has a separate threadprivate memory, i.e., thread-local storage, for each thread that uses it. The threadprivate memory is allocated during runtime. To access threadprivate data, a compiler needs to generate code to get the thread-local storage. The code to get the thread-local storage is to call runtime routine(s). This can be very time consuming, as it involves function calls, thread locking and memory traffic.
The IBM® XL compiler supports the threadprivate mechanism by which the compiler replaces references of threadprivate variables with function calls to the XL SMP (Symmetric Multiprocessing) runtime routines to get the address of the threadprivate memory. Linux compilers support the mechanism for thread-local variables specified with keyword _thread with support from the linker, dynamic linker and system libraries by calling runtime routine _tls_get_addr( ) to get the memory address of thread-local variables. Since runtime routine calls are expensive, it is desirable to minimize runtime routine call times to get the threadprivate memory for threadprivate variables.
There is, accordingly, a need for a mechanism for reducing threadprivate memory reference overhead in the presence of threadprivate variables in parallel programs during program compilation.